<template>
  <div>
    <!-- 订单模块下属六个页面
    1.订单信息 2.超时订单 3.进出信息 4.订单评论 5.订单日志(本页面) 6.物业流水 -->
    <div style="padding-bottom:5px">
      <el-button @click="showWindow">查询</el-button>
    </div>

    <el-table :data="page.records">
      <el-table-column
        label="订单编号"
        prop="orderInfoNum"
        width="150px">
      </el-table-column>
      <el-table-column
        label="日志时间"
        prop="logsUpdateTime"
        width="150px">
      </el-table-column>
      <el-table-column
        label="日志人类型"
        prop="logsPersonType"
        width="150px">
      </el-table-column>
      <el-table-column
        label="日志人"
        prop="logsUpdatePerson"
        width="150px">
      </el-table-column>
      <el-table-column
        label="日志描述"
        prop="orderLogsDescribe"
        width="400px">
      </el-table-column>
    </el-table>

    <div style="padding-top:5px">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.current"
        :page-sizes="[3,5,7]"
        :page-size="page.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total">
      </el-pagination>
    </div>

    <el-dialog :visible.sync="window">
      <div style="padding-bottom:10px">
      <el-input placeholder="请输入日志人" style="width:200px" v-model="logSelect.logsUpdatePerson"></el-input>
      &nbsp;
      <el-input placeholder="请输入订单编号" style="width:200px" v-model="logSelect.orderInfoNum"></el-input>
      </div>
      <div style="padding-bottom:10px">
      <el-date-picker v-model="logSelect.startTime" value-format="yyyy-MM-dd HH:mm:ss"  type="datetime" placeholder="选择开始时间"></el-date-picker>
      &nbsp;
      <el-date-picker v-model="logSelect.endTime" value-format="yyyy-MM-dd HH:mm:ss"  type="datetime" placeholder="选择结束时间"></el-date-picker>
      </div>
      <el-select v-model="logSelect.logsPersonType" placeholder="请选择日志人类型">
        <el-option value="0" label="系统"></el-option>
        <el-option value="1" label="用户"></el-option>
        <el-option value="2" label="物业"></el-option>
      </el-select>
      <div style="padding-top:10px">
        <el-button @click="window=false">取 消</el-button>
        <el-button @click="showLogs">查 询</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
export default {
  name: 'OrderLog',
  data () {
    return {
      page: [],
      window: false,
      logSelect: {
        startTime: "",
        endTime: "",
        orderInfoNum: "",
        logsPersonType: "",
        logsUpdatePerson: ""
      },
      logSelected: {
        startTime: "",
        endTime: "",
        orderInfoNum: "",
        logsPersonType: "",
        logsUpdatePerson: ""
      }
    }
  },
  methods:{
    showWindow(){
      this.logSelect.startTime = ""
      this.logSelect.endTime = ""
      this.logSelect.orderInfoNum = ""
      this.logSelect.logsPersonType = ""
      this.logSelect.logsUpdatePerson = ""
      this.window = true
    },
    showLogs(){
      this.logSelected.startTime = this.logSelect.startTime
      this.logSelected.endTime = this.logSelect.endTime
      this.logSelected.orderInfoNum = this.logSelect.orderInfoNum
      this.logSelected.logsPersonType = this.logSelect.logsPersonType
      this.logSelected.logsUpdatePerson = this.logSelect.logsUpdatePerson
      this.showLogsProper("","")
      this.window = false
    },
    showLogsProper(pageNum,pageSize){
      this.$http.get("/order/orderLogs/findOrderLogs.certified",{
        params:{
          pageNum:pageNum==""?1:pageNum,
          pageSize:pageSize==""?3:pageSize,
          startTime: this.logSelected.startTime,
          endTime: this.logSelected.endTime,
          logsPersonType: this.logSelected.logsPersonType,
          orderInfoNum: this.logSelected.orderInfoNum==""?null:this.logSelected.orderInfoNum,
          logsUpdatePerson: this.logSelected.logsUpdatePerson==""?null:this.logSelected.logsUpdatePerson
        }
      }).then(resp=>{　
        if(resp.data.flag) this.page = resp.data.data
        else this.$alert(resp.data.message)　　
      })
    },
    handleSizeChange(val) {
      this.showLogsProper("",val)
    },
    handleCurrentChange(val) {
      this.showLogsProper(val,this.page.size)
    }
  },
  created(){
    this.showLogsProper("","")
  }
}
</script>

<style>
</style>
